package com.springboot.entity;

import com.baomidou.mybatisplus.annotation.IdType;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.springboot.returndata.dto.blog.UserEamilRegisterDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

/**
 * <p>
 * 博客用户
 * </p>
 *
 * @author zyj
 * @since 2023-05-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("blog_user")
public class BlogUserEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 名称
     */
    @TableField("user_name")
    private String userName;

    /**
     * 邮箱
     */
    @TableField("user_email")
    private String userEmail;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 密码
     */
    @TableField("passwd")
    private String passwd;

    /**
     * 头像
     */
    @TableField("user_header")
    private String userHeader;

    public BlogUserEntity(){}

    public static BlogUserEntity cover(UserEamilRegisterDto userEamilRegisterDto){
        BlogUserEntity blogUserEntity = new BlogUserEntity();
        BeanUtils.copyProperties(userEamilRegisterDto, blogUserEntity);

        return blogUserEntity;
    }

}
